package cn.ldh.sync_02;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

/**
 * 同步
 */
public class Producer {

    public static void main(String[] args) throws Exception {

        // 1 创建生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("sync_producer_group");

        // 2 设置地址
        producer.setNamesrvAddr("localhost:9876");

        // 3 启动
        producer.start();

        // 4 创建短信
        Message message = new Message("sync_log", "hello", "欢迎来到猫咪学院！".getBytes(StandardCharsets.UTF_8));

        // 5 发送短信
        producer.send(message);

        // 关闭
        producer.shutdown();

    }


}
